package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteFileDataService;
import com.ruoyi.system.api.RemoteSerialDataService;
import com.ruoyi.system.api.domain.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;
import java.util.Map;

/**
 * 文件服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteSerialDataFallbackFactory implements FallbackFactory<RemoteSerialDataService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteSerialDataFallbackFactory.class);

    @Override
    public RemoteSerialDataService create(Throwable throwable)
    {
        log.error("编号数据服务调用失败:{}", throwable.getMessage());
        return new RemoteSerialDataService()
        {
            @Override
            public R<SysSerialMax> getSerialValueByParmas(Map paramMap)
            {
                return R.fail("生成编号数据时失败:" + throwable.getMessage());
            }

            @Override
            public R<SysSerialMax> saveSerialData(Map paramMap)
            {
                return R.fail("保存编号数据时失败:" + throwable.getMessage());
            }

            @Override
            public R<SysSerialMax> saveSerialData(int typeId)
            {
                return R.fail("保存编号数据时失败:" + throwable.getMessage());
            }
        };
    }
}
